﻿using System;
using Google.Protobuf;

namespace CostomGameServer
{

	static internal class ProtobufFormatter
	{
		public static byte[ ] Serialize<T>(T o) where T : IMessage {
			byte[ ] data = o.ToByteArray( );
			return data;
		}

		public static T Deserialize<T>(byte[ ] data) where T : class, IMessage, new() {
			T o = new T( );
			IMessage message = o.Descriptor.Parser.ParseFrom( data );
			return message as T;
		}
	}

}